package com.zby.lease.common.security;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;


@Configuration
@EnableWebSecurity
public class SecurityConfig {

    // 配置HTTP安全过滤链
    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
            http
                    .authorizeHttpRequests((requests) -> requests
                // 允许特定路径无需认证
                .requestMatchers("/admin/**","/**","/doc.html").permitAll()
//                  .requestMatchers("/admin/login/**").permitAll()
                .anyRequest().authenticated()
                )// 禁用CSRF保护（仅适用于开发环境，生产环境中应谨慎处理）
                    .csrf().disable();
        // 构建HTTP安全配置并返回
        return http.build();
    }

}

